<?php

/**
 * Description of AddPermission
 *
 * @author Ghazy
 */

class Application_Form_AddPermission extends Zend_Form{
    public function  init() {
        $this->setMethod('post');

        $name = new Zend_Form_Element_Text('name');
        $name->setLabel('Permission_Name')
             ->setRequired(true)
             ->addFilter(new Zend_Filter_HtmlEntities())
             ->addFilter(new Zend_Filter_StringTrim())
             ->addValidator('NotEmpty',true);


        $roles = new Zend_Form_Element_MultiCheckbox('roles');
        $roles->setLabel('Roles:');
        $q = Doctrine_Query::create()->from('TblRole r');
        $q_roles = $q->execute();
        foreach($q_roles as $q_r)
        {
            $array[$q_r['id']] = $q_r->name;
        }
        $roles->setMultiOptions($array);
        $roles->setRequired(true);

        $resources = new Zend_Form_Element_Text('resources');
        $resources->setLabel('resources')
             ->setRequired(true)
             ->addFilter(new Zend_Filter_HtmlEntities())
             ->addFilter(new Zend_Filter_StringTrim())
             ->addValidator('NotEmpty',true);



        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Add_Permission');


        $reset = new Zend_Form_Element_Reset('reset');
        $reset->setLabel('Reset');

        $this->addElement($name)
             ->addElement($roles)
             ->addElement($resources)
             ->addElement($reset)
             ->addElement($submit);
    }
}
?>
